// 虚函数与形状

#include <iostream>
using namespace std;

class Shape {
public:
    virtual void WhatAmI() {
        cout << "这是基本形状\n";
    }
};

class Pyramid : public Shape {
public:
    void WhatAmI() override {
        cout << "这是金字塔形状\n";
    }
};

class Sphere : public Shape {
public:
    void WhatAmI() override {
        cout << "这是球形\n";
    }
};

class Box : public Shape {
public:
    void WhatAmI() override {
        cout << "这是立方体型\n";
    }
};

class Cone : public Shape {
public:
    void WhatAmI() override {
        cout << "这是圆锥型\n";
    }
};


int main() {
    cout << "虚形状程序\n";

    Cone    myCone;
    Sphere  mySphere;
    Pyramid myPyramid;
    Box     myBox;

    Shape* base[4] = {
        &myCone,
        &mySphere,
        &myPyramid,
        &myBox
    };

    for (auto s : base) {
        s->WhatAmI();
    }

    cout << "好了，这会儿简单一些了\n";
}